<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>亚美O2O服务平台-广州亚美科技有限公司</title>
<jsp:include page="../meta.jsp" />

<style>
body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, code, form, fieldset, legend, input, button, textarea, p, blockquote, th, td { margin: 0; padding: 0; }
fieldset, img { border: 0; }
img { display:inline-block; }
:focus { outline: 0; }
address, caption, cite, code, dfn, em, strong, th, var, optgroup { font-style: normal; font-weight: normal; }
h1, h2, h3, h4, h5, h6 { font-size: 100%; font-weight: normal; }
abbr, acronym { border: 0; font-variant: normal; }
input, button, textarea, select, optgroup, option { font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; }
code, kbd, samp, tt { font-size:100%; }
input, button, textarea, select { *font-size: 100%;
}
ol, ul { list-style: none outside none; }
table { border-collapse: collapse; border-spacing: 0; }
caption, th { text-align: left; }
sup, sub { font-size: 100%; vertical-align: baseline; }
:link, :visited, ins { text-decoration: none; }
blockquote, q { quotes: none; }
blockquote:before, blockquote:after, q:before, q:after { content: ''; content: none; }
/**/
html, body { border:none 0; }
body { font-size:75%; color:#666; font-family:'Microsoft Yahei', Tahoma, Arial!important; font-family:'宋体', Tahoma, Arial; text-align:center; }
a { color:#214FA3; }
a:hover { text-decoration:underline; }
#password-form { padding-top:30px; }
#password-form p { padding:5px;  text-align:right; }
#password-form input { width:15em; padding:4px; border:1px solid #CCC; }
#password-form input:focus { border-color:#426DC9; }
#password-form .password-form-error { background:#FFFBFC; border-color:#F00 !important; }
</style>
</head>

<body>
<!-- <div style="background:#FAFBDD; padding:3px;"><a href="javascript:art.dialog.close();">iframe中关闭</a></div> -->
<form id="password-form"  method="post" onsubmit="javascript:return false;" >
<p><label>原密码：<input id="password-form-password" title="原密码" name="password" type="password"></label></p>
<p><label>新密码：<input id="password-form-newpassword" title="新密码" name="newpassword" type="password"></label></p>
<p><label>确认密码：<input id="password-form-repassword" title="确认密码" name="repassword" type="password"></label></p>
</form>
<script>

$(document).ready(function(){
 						
//(function () {
var parent = art.dialog.parent,				// 父页面window对象
	api = art.dialog.open.api,	// 			art.dialog.open扩展方法
	//$ = function (id) {return document.getElementById(id)},
	form = $("#password-form"),
	password = $("#password-form-password"),
	newpassword = $("#password-form-newpassword");
	repassword = $("#password-form-repassword");

if (!api) return;

parent.document.title = '亚美O2O服务平台-广州亚美科技有限公司';

// 操作对话框
api.title('修改密码')
	// 自定义按钮
	.button(
		{
			name: '确定',
			callback: function () {
				if (check(password) && check(newpassword)&& check(repassword) && compare(newpassword,repassword)){
					$.ajax({
					   type: "POST",
					   dataType:"json",
					   url: "${pageContext.request.contextPath}/modify-password",
					   data: "password="+$("#password-form-password").val()+ "&newpassword="+$("#password-form-newpassword").val()+"&repassword="+$("#password-form-repassword").val()+ "&t="+Math.random(),
					   success: function(responseText){
							if( responseText.code == 0 ){
							 	  art.dialog.tips("<p style='color:green;'>修改成功</p>", 0.8);
							 	  setTimeout(function(){api.close(); }, 1000);
						  	 	  return true;
						   }else{
							   //有错误
							    art.dialog.tips("<p style='color:red;'>修改失败:"+responseText.msg+"</p>", 1.5);
							   return false;
						   }
						
					   }
					});

				}
				return false;
			},
			focus: true
		},
		{
			name: '取消'
		}
	);

// 表单验证
var check = function (input) {
	if (input.val() === '') {

		input.focus();
		art.dialog.tips("<p style='color:red;'>请填写"+input.attr("title")+"</p>", 0.8);
		return false;
	} else {
		return true;
	};
};

// 表单验证
var compare = function (mInput,nInput) {

	if (mInput.val() == nInput.val()) {

		return true;
	} else {

		nInput.focus();
		art.dialog.tips("<p style='color:red;'>新密码与确认密码不一致，请重新填写</p>", 0.8);
	
		return false;
	};
};



window.onload = function () {setTimeout(function () {password.focus()}, 240);};

//})();

});
</script>
</body>
</html>
